package com.cb.domain.dao.system.impl;

import java.util.List;
import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.cb.core.dao.hibernate.GenericDAOHibernate;
import com.cb.domain.model.system.Media;
import com.cb.domain.dao.system.MediaDAO;
import com.cb.core.webapp.paging.PagingBean;

@Repository
public class MediaDAOImpl extends GenericDAOHibernate<Media, Long> implements MediaDAO {
	public MediaDAOImpl() {
		super(Media.class);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public List<Media> getByVo(Media vo, PagingBean pb) {
		List<Object>paramList=new ArrayList<Object>();
		String hql="from Media vo where 1=1";
		
		/**TODO 添加自己的需要加入的查询条件
		if(StringUtils.isNotEmpty(vo.getUsername())){
			hql+=" and vo.username like ?";
			paramList.add("%"+vo.getUsername()+"%");
		}**/
		
		List <Media>list=this.find(hql, paramList.toArray(), pb);
		return list;
	}

	@Override
	public Media getMediaBySort(int sort) {
		String hql="from Media m where m.sort=?";
		return (Media)this.findUnique(hql,new Object[]{sort});
	}
}

